* SOEP-Long
* File paths need to be replaced for each file 
* This needs 5 files:
*	-ppathl, pl, pgen, hbrutto
*

cd ""

* Replace above with directory that contains SOEP


***********************
* Rooting File:
use "ppathl.dta", replace 

keep pid persnr piyear syear cid sex gebjahr hid sampreg germborn corigin migback  
keep if syear >= 2000 & syear <= 2010

save ppathl_small.dta, replace


***********************
*** pl is raw data
* get resp. attitudes
 use "pl.dta" , replace
 keep pid syear p_nace plh0032 plh0033 plh0126 plh0127
 
 save pl_small.dta, replace

*********************** 
* pg generated file
 use "pgen.dta", replace
	keep pid syear pglfs pgpsbil pgisced11 pgnace
  save pgen_small.dta, replace

	
****************************** 
  use "hbrutto.dta", replace
	keep hid syear bula
  save hbrutto_small.dta, replace
 
* merge 1:many 
* pid = personID
* hid = householdID
*syear = survey year

use ppathl_small.dta, replace 

* pl

merge 1:m pid syear using pl_small.dta
keep if _merge == 3
drop _merge

* pgen

merge 1:m pid syear using pgen_small.dta
keep if _merge == 3
drop _merge

* hbrutto

merge m:m hid syear using hbrutto_small.dta
keep if _merge == 3
drop _merge

** this is the file for the analysis code 

save soep.dta, replace 

